#include <bits/stdc++.h>
using namespace std;
int T, n, ans, a[114514], co[114514];
void dfs(int x) {
    if (x == n + 1) {
        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i - 1; j >= 1; --j) {
                if (co[j] == co[i]) {
                    if (a[i] == a[j]) cnt += a[i];
                    break;
                }
            }
        }
        ans = max(ans, cnt);
        return;
    }
    co[x] = 1;
    dfs(x + 1);
    co[x] = 0;
    dfs(x + 1);
}
int main() {
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    cin >> T;
    while (T--) {
        ans = 0;
        cin >> n;
        for (int i = 1; i <= n; ++i) cin >> a[i];
        dfs(1);
        cout << ans << endl;
    }
    return 0;
}
